package com.se2.antiqueexhibition.Controller;

import com.se2.antiqueexhibition.Service.CulturalRelicService;
import com.se2.antiqueexhibition.pojo.CulturalRelic;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@RequestMapping
@Controller
public class CulturalRelicController {
    @Resource
    private CulturalRelicService culturalRelicService;

    @RequestMapping("/antiquelist")
    public String antiquelist(ModelMap model) {
        List<CulturalRelic> culturalRelicList = culturalRelicService.getAllCulturalRelic();
        model.put("culturalRelicList", culturalRelicList);
        System.out.println(culturalRelicList);
        return "antiquelist";
    }

    @RequestMapping("/antique/{id}")
    public String antique(@PathVariable int id, ModelMap model) {
        CulturalRelic culturalRelic = culturalRelicService.getCulturalRelicById(id);
        model.put("culturalRelic", culturalRelic);
        return "antique";
    }
}
